import urllib
from urllib import request

#urllib 在python2 中是 urllib2 python3 就是 urllib.request

headers = {
    "User-Agent":"User-Agent,Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11"
}

url = "http://www.qfedu.com/"

#创建请求对象
req = urllib.request.Request(url,headers=headers)

#获取相应
res = urllib.request.urlopen(req)

# print(res)
# print(res.read())
print(res.read().decode('utf-8'))
#字符串到字节 encode   转码
#字节到字符串  decode   解码